import java.util.*;

public class Main1812 {

    static Comparator<Integer> cmp =new Comparator<Integer>() {
    public int compare(Integer a, Integer b) {return b-a; }
};

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr,cmp);
        List list = new ArrayList();
        for(int i=0;i<arr.length;i++){
            if(!list.contains(arr[i])){
                list.add(arr[i]);
            }
        }
        Object[] newArr = list.toArray();
        for (int i=1;i<newArr.length;i++){
            System.out.println(newArr[i]);
            break;
        }
    }
}
